package com.itheima.method;

/**
 * @Author 王加鑫
 * @Date 2021/4/22 16:46
 * @Version 1.0
 * 打印数组
 */
public class ForArrayTest01 {
    public static void main(String[] args) {
        int[] arr = {10,20,30,40,50};
        int[] arr1 = {3000,89999,56666,45,121,89,78,45,63,32};
        printArray(arr1);
        printArray(arr);

    }

    /*
    打印数组
     */
    public static void printArray(int[] arr){
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] != arr[arr.length-1]){
                System.out.print(arr[i] + ",");
            }else {
                System.out.println(arr[i] + "]");
            }
        }
    }
}
